VERSION 5.00
Object = "{0BA686C6-F7D3-101A-993E-0000C0EF6F5E}#1.0#0"; "THREED32.OCX"
Object = "{C932BA88-4374-101B-A56C-00AA003668DC}#1.1#0"; "MSMASK32.OCX"
Object = "{BEEECC20-4D5F-4F8B-BFDC-5D9B6FBDE09D}#1.0#0"; "vsflex8.ocx"
Begin VB.Form FrmPedidos 
   BorderStyle     =   3  'Fixed Dialog
   Caption         =   "Actualizacion de Pedidos"
   ClientHeight    =   4425
   ClientLeft      =   45
   ClientTop       =   360
   ClientWidth     =   8325
   Icon            =   "FrmTraePedidos.frx":0000
   LinkTopic       =   "Form1"
   LockControls    =   -1  'True
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   4425
   ScaleWidth      =   8325
   ShowInTaskbar   =   0   'False
   Begin Threed.SSFrame SSFrame1 
      Height          =   4440
      Left            =   0
      TabIndex        =   5
      Top             =   -75
      Width           =   8295
      _Version        =   65536
      _ExtentX        =   14631
      _ExtentY        =   7832
      _StockProps     =   14
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Begin Threed.SSPanel SSPanel2 
         Height          =   450
         Left            =   90
         TabIndex        =   6
         Top             =   90
         Width           =   8190
         _Version        =   65536
         _ExtentX        =   14446
         _ExtentY        =   794
         _StockProps     =   15
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Begin MSMask.MaskEdBox mskFechaIni 
            Height          =   300
            Left            =   5175
            TabIndex        =   0
            Top             =   75
            Width           =   1140
            _ExtentX        =   2011
            _ExtentY        =   529
            _Version        =   393216
            AutoTab         =   -1  'True
            MaxLength       =   10
            Mask            =   "##/##/####"
            PromptChar      =   "_"
         End
         Begin MSMask.MaskEdBox mskFechaFin 
            Height          =   300
            Left            =   6645
            TabIndex        =   1
            Top             =   75
            Width           =   1140
            _ExtentX        =   2011
            _ExtentY        =   529
            _Version        =   393216
            AutoTab         =   -1  'True
            MaxLength       =   10
            Mask            =   "##/##/####"
            PromptChar      =   "_"
         End
         Begin VB.Label LblDesVen 
            BackStyle       =   0  'Transparent
            BorderStyle     =   1  'Fixed Single
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   9
               Charset         =   0
               Weight          =   700
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   300
            Left            =   1410
            TabIndex        =   11
            Top             =   75
            Width           =   2970
         End
         Begin VB.Label Label1 
            BackStyle       =   0  'Transparent
            Caption         =   "Vendedor"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   700
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            ForeColor       =   &H00000080&
            Height          =   195
            Left            =   45
            TabIndex        =   10
            Top             =   105
            Width           =   810
         End
         Begin VB.Label LblVendedor 
            Alignment       =   2  'Center
            BackStyle       =   0  'Transparent
            BorderStyle     =   1  'Fixed Single
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   9
               Charset         =   0
               Weight          =   700
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   300
            Left            =   990
            TabIndex        =   9
            Top             =   75
            Width           =   405
         End
         Begin VB.Label Label2 
            BackStyle       =   0  'Transparent
            Caption         =   "Fechas"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   700
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            ForeColor       =   &H00000080&
            Height          =   195
            Left            =   4470
            TabIndex        =   8
            Top             =   105
            Width           =   600
         End
         Begin VB.Label Label3 
            Caption         =   "Al"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   700
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   195
            Left            =   6375
            TabIndex        =   7
            Top             =   105
            Width           =   210
         End
      End
      Begin VSFlex8Ctl.VSFlexGrid VSDetalle 
         Height          =   2070
         Left            =   75
         TabIndex        =   4
         Top             =   2310
         Width           =   8115
         _cx             =   14314
         _cy             =   3651
         Appearance      =   1
         BorderStyle     =   1
         Enabled         =   -1  'True
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         MousePointer    =   0
         BackColor       =   -2147483643
         ForeColor       =   -2147483640
         BackColorFixed  =   -2147483633
         ForeColorFixed  =   -2147483630
         BackColorSel    =   8388608
         ForeColorSel    =   -2147483634
         BackColorBkg    =   -2147483636
         BackColorAlternate=   -2147483643
         GridColor       =   -2147483633
         GridColorFixed  =   -2147483632
         TreeColor       =   -2147483632
         FloodColor      =   192
         SheetBorder     =   -2147483642
         FocusRect       =   1
         HighLight       =   1
         AllowSelection  =   -1  'True
         AllowBigSelection=   -1  'True
         AllowUserResizing=   0
         SelectionMode   =   0
         GridLines       =   1
         GridLinesFixed  =   2
         GridLineWidth   =   1
         Rows            =   2
         Cols            =   5
         FixedRows       =   1
         FixedCols       =   0
         RowHeightMin    =   0
         RowHeightMax    =   0
         ColWidthMin     =   0
         ColWidthMax     =   0
         ExtendLastCol   =   0   'False
         FormatString    =   $"FrmTraePedidos.frx":000C
         ScrollTrack     =   0   'False
         ScrollBars      =   3
         ScrollTips      =   0   'False
         MergeCells      =   0
         MergeCompare    =   0
         AutoResize      =   -1  'True
         AutoSizeMode    =   0
         AutoSearch      =   0
         AutoSearchDelay =   2
         MultiTotals     =   -1  'True
         SubtotalPosition=   1
         OutlineBar      =   0
         OutlineCol      =   0
         Ellipsis        =   0
         ExplorerBar     =   0
         PicturesOver    =   0   'False
         FillStyle       =   0
         RightToLeft     =   0   'False
         PictureType     =   0
         TabBehavior     =   0
         OwnerDraw       =   0
         Editable        =   2
         ShowComboButton =   1
         WordWrap        =   0   'False
         TextStyle       =   0
         TextStyleFixed  =   0
         OleDragMode     =   0
         OleDropMode     =   0
         DataMode        =   0
         VirtualData     =   -1  'True
         DataMember      =   ""
         ComboSearch     =   3
         AutoSizeMouse   =   -1  'True
         FrozenRows      =   0
         FrozenCols      =   0
         AllowUserFreezing=   0
         BackColorFrozen =   0
         ForeColorFrozen =   0
         WallPaperAlignment=   9
         AccessibleName  =   ""
         AccessibleDescription=   ""
         AccessibleValue =   ""
         AccessibleRole  =   24
      End
      Begin VSFlex8Ctl.VSFlexGrid VsCabecera 
         Height          =   1380
         Left            =   75
         TabIndex        =   2
         Top             =   540
         Width           =   8115
         _cx             =   14314
         _cy             =   2434
         Appearance      =   1
         BorderStyle     =   1
         Enabled         =   -1  'True
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         MousePointer    =   0
         BackColor       =   -2147483643
         ForeColor       =   -2147483640
         BackColorFixed  =   -2147483633
         ForeColorFixed  =   -2147483630
         BackColorSel    =   -2147483635
         ForeColorSel    =   -2147483634
         BackColorBkg    =   -2147483636
         BackColorAlternate=   -2147483643
         GridColor       =   -2147483633
         GridColorFixed  =   -2147483632
         TreeColor       =   -2147483632
         FloodColor      =   192
         SheetBorder     =   -2147483642
         FocusRect       =   1
         HighLight       =   0
         AllowSelection  =   -1  'True
         AllowBigSelection=   -1  'True
         AllowUserResizing=   0
         SelectionMode   =   0
         GridLines       =   1
         GridLinesFixed  =   2
         GridLineWidth   =   1
         Rows            =   2
         Cols            =   4
         FixedRows       =   1
         FixedCols       =   0
         RowHeightMin    =   0
         RowHeightMax    =   0
         ColWidthMin     =   0
         ColWidthMax     =   0
         ExtendLastCol   =   0   'False
         FormatString    =   $"FrmTraePedidos.frx":00C0
         ScrollTrack     =   0   'False
         ScrollBars      =   3
         ScrollTips      =   0   'False
         MergeCells      =   0
         MergeCompare    =   0
         AutoResize      =   -1  'True
         AutoSizeMode    =   0
         AutoSearch      =   0
         AutoSearchDelay =   2
         MultiTotals     =   -1  'True
         SubtotalPosition=   1
         OutlineBar      =   0
         OutlineCol      =   0
         Ellipsis        =   0
         ExplorerBar     =   0
         PicturesOver    =   0   'False
         FillStyle       =   0
         RightToLeft     =   0   'False
         PictureType     =   0
         TabBehavior     =   0
         OwnerDraw       =   0
         Editable        =   0
         ShowComboButton =   1
         WordWrap        =   0   'False
         TextStyle       =   0
         TextStyleFixed  =   0
         OleDragMode     =   0
         OleDropMode     =   0
         DataMode        =   0
         VirtualData     =   -1  'True
         DataMember      =   ""
         ComboSearch     =   3
         AutoSizeMouse   =   -1  'True
         FrozenRows      =   0
         FrozenCols      =   0
         AllowUserFreezing=   0
         BackColorFrozen =   0
         ForeColorFrozen =   0
         WallPaperAlignment=   9
         AccessibleName  =   ""
         AccessibleDescription=   ""
         AccessibleValue =   ""
         AccessibleRole  =   24
      End
      Begin Threed.SSCommand CmdSalir 
         Height          =   315
         Left            =   7725
         TabIndex        =   3
         ToolTipText     =   "Analizar Mejores Precios del Proveedor"
         Top             =   1950
         Width           =   465
         _Version        =   65536
         _ExtentX        =   820
         _ExtentY        =   556
         _StockProps     =   78
         Outline         =   0   'False
         Picture         =   "FrmTraePedidos.frx":0163
      End
   End
End
Attribute VB_Name = "FrmPedidos"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Public Sub Cargar_Pedidos()
On Error GoTo Mio
    Dim Rs_CabPed As New ADODB.Recordset, FilaActual As Integer, i As Integer
    Set Rs_CabPed = CLS_COMANDO.Ejec_Comando_1("Spu_Inv_Trae_PedidosFac", gbCodEmpresa, Trim$(LblVendedor), "FA02NROPEDIDO", "*", Trim$(mskFechaIni), Trim$(mskFechaFin), Trim$(LblVendedor))
    VsCabecera.Rows = 2
    If Rs_CabPed.RecordCount > 0 Then
        Rs_CabPed.MoveFirst
        For i = 1 To Rs_CabPed.RecordCount
           With VsCabecera
                FilaActual = .Rows - 1
                .TextMatrix(FilaActual, 0) = Trim$(Rs_CabPed("FA02NROPEDIDO"))
                .TextMatrix(FilaActual, 1) = Trim$(Rs_CabPed("FA02FECPED"))
                .TextMatrix(FilaActual, 2) = Trim$(Rs_CabPed("FA02RAZON"))
                .TextMatrix(FilaActual, 3) = Format(Rs_CabPed("FA02IMPBRUTO"), "##,#0.00")
                .Rows = .Rows + 1
           End With
           Rs_CabPed.MoveNext
        Next
        VsCabecera.Rows = VsCabecera.Rows - 1
        VsCabecera.Col = 0
        Set Rs_CabPed = Nothing
    End If
    Exit Sub
Mio:
    MsgBox Err.Description, vbInformation + vbCritical
End Sub
    
Sub CargaDetalle(NrPedido As String)
    Dim Rs_Detalle As New ADODB.Recordset, FilaDet As Integer, i As Integer
    Set Rs_Detalle = CLS_COMANDO.Ejec_Comando_1("Spu_Inv_Trae_FacDetalle_Pedido", gbCodEmpresa$, Trim$(LblVendedor), gbAno$, NrPedido)
    If Rs_Detalle.RecordCount > 0 Then
       VSDetalle.Rows = 2
       Rs_Detalle.MoveLast: Rs_Detalle.MoveFirst
       For i = 1 To Rs_Detalle.RecordCount
        With VSDetalle
            FilaDet = .Rows - 1
            .TextMatrix(FilaDet, 0) = Trim$(Rs_Detalle("FA03ARTICULO"))
            .TextMatrix(FilaDet, 1) = Trim$(Rs_Detalle("In01Deslar"))
            .TextMatrix(FilaDet, 2) = Trim$(Rs_Detalle("FA03UNIDADMEDIDA"))
            .TextMatrix(FilaDet, 3) = Trim$(Rs_Detalle("FA03CANTIDAD")) - Trim$(Rs_Detalle("FA03CANATEP"))
            .TextMatrix(FilaDet, 4) = Trim$(Rs_Detalle("FA03CODALM"))
            .Rows = .Rows + 1
        End With
        Rs_Detalle.MoveNext
       Next i
       VSDetalle.Rows = VSDetalle.Rows - 1
       VsCabecera.Col = 1
       Set Rs_Detalle = Nothing
    End If
End Sub
    
Private Sub CmdSalir_Click()
On Error GoTo Mio
    Dim ctFila As Integer, ctLinea As String
    Call Crear_TablaDetalle
    With VSDetalle
        ctFila = .Row
        ctLinea = DameDescripcion(gbCodEmpresa + Trim$(.TextMatrix(ctFila, 0)), "CODLINEA")
        Call Inserta_TablaDetalle(.TextMatrix(ctFila, 0), .TextMatrix(ctFila, 1), .TextMatrix(ctFila, 2), .TextMatrix(ctFila, 3), .TextMatrix(ctFila, 4))
    End With
    With FabcProduccion.tblDetalle
        .Columns(0).DataField = "Articulo"
        .Columns(1).DataField = "Descripcion"
        .Columns(2).DataField = "Unidad"
        .Columns(3).DataField = "Cantidad"
        .Columns(4).DataField = "Almacen"
        .DataSource = Ry_Detalle
    End With
    Ry_Detalle.MoveFirst
    ctFila = VsCabecera.Row
    '--------------------------------------------------------------------------------------
    With FabcProduccion
        .TxtResponsable = DameDescripcion(gbCodEmpresa + ctLinea, "CODJEFE")
        .LblJefeLinea = DameDescripcion(gbCodEmpresa + ctLinea, "JEFE")
        .TxtOrdenInterna = VsCabecera.TextMatrix(ctFila, 0)
        .LblTipoL = Trim$(ctLinea)
        .LblLinea.Caption = DameDescripcion(Trim$(gbCodEmpresa$ + ctLinea), "TIPOLINEA")
        .TxtGlosa.Text = DameDescripcion_GL(Trim$(gbCodEmpresa + gbAno + .TxtVendedor + .TxtOrdenInterna), "GLOSAPED")
    End With
    '--------------------------------------------------------------------------------------
    Unload Me
    FabcProduccion.TxtResponsable.SetFocus
    Exit Sub
Mio:
    MsgBox Err.Description, vbInformation + vbCritical
End Sub

Private Sub Form_Load()
Call PunteroRelojDeArena
Call CentraPantalla(Me)
LblVendedor.Caption = Trim$(FabcProduccion.TxtVendedor)
LblDesVen.Caption = DameDescripcion(Trim$(gbCodEmpresa$ + LblVendedor), "VENDEDOR")
mskFechaIni.Text = Format("01/" & gbMes & "/" & gbAno, "dd/mm/yyyy")
mskFechaFin.Text = Format(UltimoDia(gbMes$) + "/" + gbMes + "/" + gbAno$, "dd/mm/yyyy")
Call Cargar_Pedidos
Call CargaDetalle(VsCabecera.TextMatrix(VsCabecera.Row, 0))
Call PunteroNormal
End Sub

Private Sub mskFechaFin_GotFocus()
Call MarcaGet(mskFechaFin)
End Sub

Private Sub mskFechaFin_KeyPress(KeyAscii As Integer)
Ftab KeyAscii
If KeyAscii = 13 Then
    Call Cargar_Pedidos
    Call CargaDetalle(VsCabecera.TextMatrix(VsCabecera.Row, 0))
End If
End Sub

Private Sub mskFechaIni_GotFocus()
Call MarcaGet(mskFechaIni)
End Sub

Private Sub mskFechaIni_KeyPress(KeyAscii As Integer)
Ftab KeyAscii
End Sub

Private Sub VsCabecera_RowColChange()
Call CargaDetalle(VsCabecera.TextMatrix(VsCabecera.Row, 0))
End Sub
